<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/1/3 0003
 * Time: 11:58
 */
//连接swoole_tcp服务
$client = new swoole_client(SWOOLE_SOCK_TCP);

if(!$client->connect('127.0.0.1', 9501)){
    echo "连接失败";
    exit();
}

//php内置 cli常量  STDOUT,STDIN
fwrite(STDOUT, "请输入消息：");  //用户输入数据
$msg = trim(fgets(STDIN));       //获取用户数据

//发送消息给tcp server服务器
$client->send($msg);

//接收来自server的数据
$result = $client->recv();
echo $result;












